Skip to content

fix(taskfiles): Improve concurrency control for external tools:#117

Merged
davidlion merged 6 commits into
y-scope:mainfrom
davidlion:concurrency-ctrl
Jul 9, 2026
Merged

fix(taskfiles): Improve concurrency control for external tools:#117
davidlion merged 6 commits into
y-scope:mainfrom
davidlion:concurrency-ctrl

Conversation

@davidlion

@davidlion davidlion commented Jun 30, 2026

Copy link
Copy Markdown
Member
  • Default to the number of logical processors.
  • Allow users to control the default through the env var TASK_EXTERNAL_TOOL_CONCURRENCY.

Description

Currently, concurrency variables are not handled consistently so a user cannot easily control the concurrency from the command line. The goal of this PR is to create a consistent flow for users to easily control concurrency in resource limited scenarios.

For example, most tasks use the variable JOBS, but cmake also has a task that uses CMAKE_JOBS and passes that value as a JOBS argument. If the user sets JOBS it will not be respected by the task using CMAKE_JOBS. This is further complicated as top-level projects (e.g. CLP) end up using their own ad-hoc variables to control concurrency.

Tasks that set a concurrency related parameter for a tool should (see PR code for example):

  1. Use the argument provided by the caller (if non-empty).
  2. Use the environment variable TASK_EXTERNAL_TOOL_CONCURRENCY (if non-empty).
  3. Fallback to the number of logical cores provided by G_NPROCS in misc.yaml.

Tasks that propagate a concurrency related parameter should:

  1. Propagate it without explicitly setting the value unless they need to always override the user.
    • e.g. if the task FOO takes a parameter JOBS_FOO and calls BAR which takes JOBS_BAR it should just directly pass the arg JOBS_BAR: {{.JOBS_FOO}}.

A user wishing to set the default concurrency value can either set TASK_EXTERNAL_TOOL_CONCURRENCY in their environment, or at the commandline: TASK_EXTERNAL_TOOL_CONCURRENCY=16 task ...

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Manually tested with the boost test and prints.

Summary by CodeRabbit

  • New Features

    • Build tasks now automatically use all available CPU cores by default when no parallelism value is provided.
    • Parallel build settings can now inherit from a shared default across related workflows.
  • Bug Fixes

    • Improved consistency in how build concurrency is handled, reducing cases where builds fell back to tool-specific defaults.
    • Updated related task defaults so build and install steps behave more predictably together.

… set by a user for concurrency related variables; Tasks that use the concurrency value default to nprocs.
@davidlion davidlion requested a review from a team as a code owner June 30, 2026 22:37
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR adds a shared G_NPROCS variable and updates boost/cmake task defaults so JOBS and CMAKE_JOBS resolve from processor count or inherited values instead of empty defaults. Related task documentation was updated.

Changes

JOBS Concurrency Defaulting

Layer / File(s) Summary
Add shared processor-count variable
exports/taskfiles/utils/misc.yaml
Adds G_NPROCS via getconf _NPROCESSORS_ONLN.
Boost JOBS defaulting
exports/taskfiles/utils/boost.yaml
Includes misc.yaml, updates build-and-install JOBS defaulting to use TASK_JOBS or G_NPROCS, and removes the empty download-and-install JOBS default.
CMake JOBS/CMAKE_JOBS defaulting
exports/taskfiles/utils/cmake.yaml
Updates build JOBS defaulting to use G_NPROCS or TASK_JOBS, and makes install-remote-tar inherit CMAKE_JOBS from JOBS when unset.

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related PRs

  • y-scope/yscope-dev-utils#64: Also updates exports/taskfiles/utils/boost.yaml around build-and-install/download-and-install JOBS defaulting.

Suggested reviewers: kirkrodrigues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the PR’s main change: standardizing concurrency defaults for taskfiles and external build tools.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
exports/taskfiles/utils/boost.yaml (1)

154-160: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Keep a local JOBS default here. download-and-install now passes {{.JOBS}} straight through to build-and-install; if it’s unset, Task will expand that to <no value>, which prevents the child task’s default .G_NPROCS .JOBS fallback from doing its job and can surface as an invalid -j value on the default path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@exports/taskfiles/utils/boost.yaml` around lines 154 - 160, The boost task
variables block is missing a local JOBS default, so when download-and-install
forwards {{.JOBS}} into build-and-install it can expand to <no value> and bypass
the child task’s fallback. Update the variables section in boost.yaml near
BUILD_DIR and BUILD_AND_INSTALL_ARGS to define JOBS with a default that falls
back to .G_NPROCS when .JOBS is unset, so build-and-install can safely receive a
valid jobs value.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@exports/taskfiles/utils/boost.yaml`:
- Around line 154-160: The boost task variables block is missing a local JOBS
default, so when download-and-install forwards {{.JOBS}} into build-and-install
it can expand to <no value> and bypass the child task’s fallback. Update the
variables section in boost.yaml near BUILD_DIR and BUILD_AND_INSTALL_ARGS to
define JOBS with a default that falls back to .G_NPROCS when .JOBS is unset, so
build-and-install can safely receive a valid jobs value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 22618304-b326-4ec4-9998-487ac7d8c79e

📥 Commits

Reviewing files that changed from the base of the PR and between 7947642 and b8491ae.

📒 Files selected for processing (3)
  • exports/taskfiles/utils/boost.yaml
  • exports/taskfiles/utils/cmake.yaml
  • exports/taskfiles/utils/misc.yaml

@davidlion davidlion requested a review from kirkrodrigues July 2, 2026 13:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
exports/taskfiles/utils/cmake.yaml (1)

172-172: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add a CMAKE_JOBS var in install-remote-tar. {{.CMAKE_JOBS}} is unset here, so build gets an empty JOBS value and falls back to its own default concurrency instead of the caller’s setting.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@exports/taskfiles/utils/cmake.yaml` at line 172, The install-remote-tar task
is missing the caller-controlled CMAKE_JOBS value, so the build step can ignore
the intended concurrency setting. Update the install-remote-tar task in the
cmake.yaml template to pass through .CMAKE_JOBS alongside the existing install
args, and ensure the build invocation uses that variable instead of leaving JOBS
empty. Use install-remote-tar and the CMAKE_JOBS/CMAKE_INSTALL_ARGS symbols to
locate the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@exports/taskfiles/utils/cmake.yaml`:
- Line 172: The install-remote-tar task is missing the caller-controlled
CMAKE_JOBS value, so the build step can ignore the intended concurrency setting.
Update the install-remote-tar task in the cmake.yaml template to pass through
.CMAKE_JOBS alongside the existing install args, and ensure the build invocation
uses that variable instead of leaving JOBS empty. Use install-remote-tar and the
CMAKE_JOBS/CMAKE_INSTALL_ARGS symbols to locate the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 51d9e739-1dc1-4704-bff2-3c77d6ce8762

📥 Commits

Reviewing files that changed from the base of the PR and between b8491ae and 8166db9.

📒 Files selected for processing (2)
  • exports/taskfiles/utils/boost.yaml
  • exports/taskfiles/utils/cmake.yaml

@davidlion davidlion changed the title fix(taskfiles): Always default to a special JOBS variable for concurrency related variables to simplify user control; Tasks that run the concurrent tools default to nprocs. fix(taskfiles): Default tasks that run the concurrent tools to try the TASK_EXTERNAL_TOOL_CONCURRENCY env variable, with nprocs as a fallback. Jul 9, 2026

@kirkrodrigues kirkrodrigues left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the PR title & body, how about:

fix(taskfiles): Improve concurrency control for external tools:
- Default to the number of logical processors.
- Allow users to control the default through the env var `TASK_EXTERNAL_TOOL_CONCURRENCY`.

@davidlion davidlion changed the title fix(taskfiles): Default tasks that run the concurrent tools to try the TASK_EXTERNAL_TOOL_CONCURRENCY env variable, with nprocs as a fallback. fix(taskfiles): Improve concurrency control for external tools: Jul 9, 2026
@davidlion davidlion merged commit 0c214c4 into y-scope:main Jul 9, 2026
8 of 9 checks passed
@davidlion davidlion deleted the concurrency-ctrl branch July 9, 2026 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants